/**
 * 费用统计
 * @author truexin
 * @date   16/11/08
 */

import {shopping} from "../const/shopping.js";
import RichText from "../components/RichText.js";
import Img from "../components/Img";
import MenuBtn from '../components/MenuBtn.js';


const lf = liefeng,
    R = React,
    RC = React.createClass,
    getUrlParam = lf.utils.getUrlParam,
    ajax = lf.utils.ajax;

let count = 2,
    menuList = [
        {
            url: "fee-home.html?type=home",
            text: '物业费',
            num: '112,112,112',
            // tip: '',
            
        },
        {
            url: "fee-home.html?type=car",
            text: '停车费',
            num: '56,056,056',
            // tip: '已抄',
        }
    
    ];

const SelectMonth = RC({
    getInitialState() {
        return {
            title: '2016年11月',
            month: new Date().getMonth() + 1,
            year: new Date().getFullYear(),
        }
    },
    
    componentWillMount() {
        
    },
    componentDidUpdate() {
        console.log(this.state.month);
        let year = new Date().getFullYear();
        let title = year + '年' + this.state.month + '月';
    },

    componentDidMount() {
        {/*let month = new Date().getMonth() + 1;*/}
        {/*let year = new Date().getFullYear();*/}
        {/*console.log(month);*/}
        {/*console.log(year);*/}

        {/*$(R.findDOMNode(this.refs.left)).on('tap', ()=> {*/}
            {/*let title = year + '年' + month + '月';*/}
            {/*// let month = this.state.month;*/}
            {/*if (this.state.month == 1) {*/}
                {/*title = (--year) + '年' + this.state.month + '月';*/}
                {/*// month == 12;*/}
            {/*} else if (this.state.month == 12) {*/}
                {/*title = (++year) + '年' + this.state.month + '月';*/}
                {/*// month == 1;*/}
            {/*} else {*/}
                {/*title = year + '年' + (--this.state.month) + '月';*/}
            {/*}*/}
            {/*this.setState({*/}
        //         title: title,
        //         // month:month
        //     })
        // })
        // $(R.findDOMNode(this.refs.right)).on('tap', ()=> {
        //     let title = year + '年' + (++this.state.month) + '月';
        //
        //     this.setState({
        //         // month: ++this.state.month,
        //         title: title,
        //     })
        // })
    },
    
    render() {
        return <div className="flex select-month">
                    <p className="flex-item">
                        <span ref='left' className="arrowleft mui-icon mui-icon-arrowleft"></span>
                        <span className=" title-name">{this.state.title}</span>
                        <span ref='right' className="arrowright mui-icon mui-icon-arrowright"></span>
                    </p>
               </div>
    }
})

const Root = RC({
    getInitialState() {
        return {}
    },
    
    componentWillMount() {
        
    },
    
    render() {
        return <div className="fee-census">
            <SelectMonth/>
            <div className="panel">
                <p className="this-month">本月收益（元）</p>
                <p className="counts">168,168,168</p>
            </div>
            <MenuBtn menuList={menuList} count={count}/>
        </div>
    }
});

lf.appJs.getUser(function (user) {
    // lf.appJs.setTitle('费用统计');
    R.render(
        <Root user={user}/>,
        document.getElementById('root'), ()=> {
            $('#root').css({
                background: '#f2f2f2',
            });
            $('html').css({
                height: '100%'
            });
            $('body').css({
                height: '100%'
            });
        }
    );
});



